package com.useeinfo.asg.modules.logging.message;

import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.IosNotification;
import cn.jpush.api.push.model.notification.Notification;
import com.useeinfo.asg.common.utils.CommUtil;
import com.useeinfo.framework.sugar.func.file.FilePathConfig;
import com.useeinfo.framework.sugar.tools.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by GeniusJ on 2017-05-22.
 */
public class JPushUtil implements Runnable{
//    private static final String APPKEY = Configuration.getConfigurationByName("APPKEY");
//    private static final String MASTERSECRET = Configuration.getConfigurationByName("MASTERSECRET");
//
//    private Information alias;//设备名
//
//
//
//    public JPushUtil(Information information){
//        this.alias=information;
//    }
//
//
    @Override
    public  void run() {

//      sendAlias(alias.getTitle(),CommUtil.null2String(alias.getSystemUser().getId()), CommUtil.null2String(alias.getId()));

    }
//
//    /**
//     * 客户端 给所有平台的一个或者一组用户发送信息
//     */
//    public static void sendAlias(String message,String  alias,String id) {
//        JPushClient jpushClient = new JPushClient(MASTERSECRET, APPKEY);
//
//        Map<String,String> extras = new HashMap<String,String>();
//        // 添加附加信息
//        extras.put("informationId",id);
//
//        PushPayload payload = allPlatformAndAlias(message, alias,extras);
//
//        try
//        {
//            jpushClient.sendPush(payload);
//        }
//        catch (APIConnectionException e)
//        {
//            System.out.println(e);
//        }
//        catch (APIRequestException e)
//        {
//            System.out.println(e);
//            System.out.println("Error response from JPush server. Should review and fix it. " + e);
//            System.out.println("HTTP Status: " + e.getStatus());
//            System.out.println("Error Code: " + e.getErrorCode());
//            System.out.println("Error Message: " + e.getErrorMessage());
//            System.out.println("Msg ID: " + e.getMsgId());
//        }
//    }
//
//
//
//    private static PushPayload allPlatformAndAlias(String alert, String alias,Map<String, String> extras)
//    {
//
//        return PushPayload
//                .newBuilder()
//                .setPlatform(Platform.all())
//                .setAudience(Audience.alias(alias))
//                        //.setMessage(Message.newBuilder().setMsgContent(alert).addExtras(extras).build())
//                .setNotification(
//                        Notification
//                                .newBuilder()
//                                .setAlert(alert)
//                                .addPlatformNotification(
//                                        AndroidNotification.newBuilder().addExtras(extras).build())
//                                .addPlatformNotification(
//                                        IosNotification.newBuilder().addExtras(extras).build())
//                                .build())
//                .setOptions(Options.newBuilder().setApnsProduction(false).build()).build();
//    }



}
